import { createRouter, createWebHistory } from 'vue-router'
import IndexPage from "./pages/index.vue"
import ArticlePage from "./pages/article/index.vue"
import CategoryPage from "./pages/category.vue"
import TagPage from "./pages/tag.vue"
import SearchPage from "./pages/search.vue"
import MessagePage from "./pages/message.vue"
import AboutPage from "./pages/about.vue"

const routes = [
  {
    name: "index",
    path: "/",
    component: IndexPage,
    meta: {
      title: "首页",
      isFullPage: false,
    }
  },
  {
    name: "category",
    path: "/category/:category_slug",
    props: (to) => ({ categorySlug: to.params.category_slug }),
    component: CategoryPage,
    // component: () => import("./pages/category.vue"),
    meta: {
      title: "分类列表",
      isFullPage: false,
    }
  },
  {
    name: "tag",
    path: "/tag/:tag_slug",
    props: (to) => ({ tagSlug: to.params.tag_slug }),
    component: TagPage,
    // component: () => import("./pages/tag.vue"),
    meta: {
      title: "标签列表",
      isFullPage: false,
    }
  },
  {
    name: "article",
    path: "/article/:article_id",
    props: (to) => ({ articleId: Number(to.params.article_id) }),
    component: ArticlePage,
    // component: () => import("./pages/article/index.vue"),
    meta: {
      title: "详情",
      isFullPage: false,
    }
  },
  {
    name: "search",
    path: "/search/:keyword",
    props: (to) => ({ keyword: to.params.keyword }),
    component: SearchPage,
    // component: () => import("./pages/search.vue"),
    meta: {
      title: "查询",
      isFullPage: false,
    }
  },
  {
    name: "message",
    path: "/message",
    component: MessagePage,
    // component: () => import("./pages/message.vue"),
    meta: {
      title: "留言板",
      isFullPage: true
    }
  },
  {
    name: "about",
    path: "/about",
    component: AboutPage,
    // component: () => import("./pages/about.vue"),
    meta: {
      title: "关于",
      isFullPage: true
    }
  }
  // {
  //   name: "error",
  //   path: "/:error(.*)",
  //   component: () => import("./pages/error.vue"),
  //   meta: {
  //     title: "错误",
  //     isFullPage: true
  //   }
  // }
];

export default createRouter({
  history: createWebHistory(),
  routes,
  linkActiveClass: "link-active",
  // scrollBehavior(to, from, savePosition) {
  //   return savePosition || savePosition()
  // }
})
